//
//  HomeTableViewCell.m
//  LINNER
//
//  Created by Kendama on 2017/10/18.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "HomeTableViewCell.h"
NSString *const HomeCellIndefine = @"HomeCell";

@implementation HomeTableViewCell

+ (instancetype)dequeueReusableWithTableView:(UITableView *)tableView
{
    HomeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:HomeCellIndefine];
    if (cell == nil)
    {
        cell = [[HomeTableViewCell alloc]init];
    }
    return cell;
}

- (instancetype)init
{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:HomeCellIndefine];
    if (self)
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self masLayoutSubview];
        
        
    }
    return self;
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;
    [self.typeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top);
        make.bottom.mas_equalTo(superView.mas_bottom);
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(20));
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (UILabel *)nameLabel
{
    if(!_nameLabel)
    {
        UIView *superView = self.contentView;
        _nameLabel = [[UILabel alloc]init];
        [superView addSubview:_nameLabel];
//        [_nameLabel setFont:[UIFont systemFontOfSize:16.f]];
    }
    return _nameLabel;
}
- (UIImageView *)typeImageView
{
    if(!_typeImageView)
    {
        UIView *superView = self.contentView;
        _typeImageView = [[UIImageView alloc]init];
        [superView addSubview:_typeImageView];
    }
    return _typeImageView;
}
- (UIButton *)stateButton
{
    if(!_stateButton)
    {
        UIView *superView = self.contentView;
        _stateButton = [[UIButton alloc]init];
        [superView addSubview:_stateButton];
        [_stateButton setTitle:MyNSLocalizedString(@"未连接") forState:UIControlStateNormal];
        [_stateButton setTitle:MyNSLocalizedString(@"已连接") forState:UIControlStateSelected];
        [_stateButton setImage:[UIImage imageNamed:@"icon_offline"] forState:UIControlStateNormal];
        [_stateButton setImage:[UIImage imageNamed:@"icon_online"] forState:UIControlStateSelected];
    }
    return _stateButton;
}


@end
